﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using TrainingReminderSystem.Model;

namespace TrainingReminderSystem.Dal
{
    /// <summary>
    /// EFCore数据库对象
    /// </summary>
    public partial class DbEntities : DbContext
    {
        #region 数据库表

        /// <summary>
        /// 客户机构培训记录
        /// </summary>
        public DbSet<SysCustomerOrganizationTrain> SysCustomerOrganizationTrain { get; set; }

        /// <summary>
        /// 客户意向记录
        /// </summary>
        public DbSet<SysCustomerIntention> SysCustomerIntention { get; set; }

        /// <summary>
        /// 客户证件
        /// </summary>
        public DbSet<SysCustomerIdCard> SysCustomerIdCard { get; set; }

        /// <summary>
        /// 推荐人所属机构
        /// </summary>
        public DbSet<ReferrerOrganizationRelation> ReferrerOrganizationRelation { get; set; }

        /// <summary>
        /// 推荐人
        /// </summary>
        public DbSet<Referrer> Referrer { get; set; }

        /// <summary>
        /// 机构
        /// </summary>
        public DbSet<Organization> Organization { get; set; }

        #endregion

        protected void OnModelCreatingAuto(ModelBuilder builder)
        {
            #region 数据库关系

            #endregion

            #region decimal精度
            
            builder.Entity<SysStore>().Property(p => p.Longitude).HasPrecision(18, 8);
            builder.Entity<SysStore>().Property(p => p.Latitude).HasPrecision(18, 8);
            builder.Entity<SysCustomerAddress>().Property(p => p.Longitude).HasPrecision(18, 8);
            builder.Entity<SysCustomerAddress>().Property(p => p.Latitude).HasPrecision(18, 8);

            #endregion
        }
    }
}
